use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize};

#[derive(Queryable, Associations, Serialize)]
#[diesel(belongs_to(super::todo::Todo))] // #[diesel(belongs_to(Todo, foreign_key = todo_id))]
#[diesel(table_name = crate::schema::users)]
pub struct User {
  pub id: i32,
  pub todo_id: i32,
  pub code: String,
  pub name: String,
  pub version: String,
  pub description: Option<String>,
  pub created_at: NaiveDateTime,
}

#[derive(Insertable, Deserialize)]
#[diesel(table_name = crate::schema::users)]
pub struct NewUser {
  pub todo_id: i32,
  pub code: String,
  pub name: String,
  pub version: String,
  pub description: Option<String>,
}

#[derive(Queryable, Deserialize)]
pub struct UpdateUser {
  pub todo_id: i32,
  pub code: String,
  pub name: String,
  pub version: String,
  pub description: Option<String>,
}
